package com.ayoka.parenting.ui.coach.myprofit;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;

import com.ayoka.parenting.R;
import com.ayoka.parenting.bean.MyProfitBean;
import com.ayoka.parenting.databinding.ActivityMyProfitBinding;
import com.ayoka.parenting.mvp.MVPBaseActivity;
import com.ayoka.parenting.ui.coach.profitrecord.ProfitRecordActivity;
import com.jincp.common.model.ToolBarOptions;
import com.jincp.common.utils.StringUtil;

import android.databinding.ViewDataBinding;
import android.view.View;

/**
 * @ProjectName: MVPPlugin.
 * @ClassName: MyProfitActivity.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/10/10 18:17.
 */
public class MyProfitActivity extends MVPBaseActivity<ActivityMyProfitBinding, MyProfitContract.View, MyProfitPresenter> implements MyProfitContract.View {

    public static void start(Activity activity) {
        Intent intent = new Intent(activity, MyProfitActivity.class);
        activity.startActivity(intent);
    }

    @Override
    protected int getContentLayout() {
        return R.layout.activity_my_profit;
    }

    @Override
    protected void initViews() {
        mDataBinding.tvContactCustomerService.setOnClickListener(this);
        mDataBinding.tvProfitRecord.setOnClickListener(this);
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        ToolBarOptions options = new ToolBarOptions(R.string.my_profit);
        options.backgroundResource = 0;
        options.navigateId = R.mipmap.icon_back_white;
        options.titleColor = Color.WHITE;
        setCustomToolBar(mDataBinding.customToolbar.toolbar, options);

        if (mPresenter != null) {
            mPresenter.getMyProfitData();
        }
    }

    @Override
    protected MyProfitPresenter getPresenter() {
        return new MyProfitPresenter();
    }

    @Override
    public void onClick(View view) {
        if (view == mDataBinding.tvContactCustomerService) {

        } else if (view == mDataBinding.tvProfitRecord) {
            ProfitRecordActivity.start(this);
        }
    }

    @Override
    public void configMyProfitData(MyProfitBean data) {
        if (data == null) return;
        mDataBinding.tvMyProfitAmount.setText(StringUtil.formatString("%.2f", Math.floor(data.InComeBalance / 100)));
        mDataBinding.tvTodayProfit.setText(StringUtil.formatString("%.2f",  Math.floor(data.TodayInCome)));
        mDataBinding.tvTotalProfit.setText(StringUtil.formatString("%.2f",  Math.floor(data.InComeTotal)));
    }
}
